package com.hospital.schedule.module.controller;


import com.hospital.common.base.Result;
import com.hospital.common.dto.schedule.module.*;
import com.hospital.common.vo.schedule.module.AddLeaveRecordDto;
import com.hospital.schedule.module.service.ITDoctorLeaveRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 医⽣请假记录表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-09-12
 */
@RestController
//@RequestMapping("/t-doctor-leave-record")
public class TDoctorLeaveRecordController {

    @Autowired
    private ITDoctorLeaveRecordService tDoctorLeaveRecordService;
    /**
     * 添加请假记录
     * @param addLeaveRecordDto
     * @return  添加成功
     */
    @PostMapping("/addLeaveRecord")
    public Result addLeaveRecord(@RequestBody AddLeaveRecordDto addLeaveRecordDto){
        return Result.success(tDoctorLeaveRecordService.addLeaveRecord(addLeaveRecordDto));
    }
    /**
     * 管理员获取请假记录
     * @param getLeaveRecordDto 请假记录请求
     * @return PageResult 请假记录
     */
    @PostMapping("/getLeaveRecord")
    public Result getLeaveRecord(@RequestBody GetLeaveRecordDto getLeaveRecordDto){
        return Result.success(tDoctorLeaveRecordService.getLeaveRecord(getLeaveRecordDto));
    }
    /**
     * 医生获取请假记录
     * @param findLeaveRecordByDoctorDto 请假记录请求
     * @return PageResult 请假记录
     */
    @PostMapping("/findLeaveRecordByDoctor")
    public Result findLeaveRecordByDoctor(@RequestBody FindLeaveRecordByDoctorDto findLeaveRecordByDoctorDto){
//        ThreadAttributes threadAttributes = ThreadLocalUtils.get();
//        findLeaveRecordByDoctorDto.setUserId(threadAttributes.getUserId());
        return Result.success(tDoctorLeaveRecordService.
                findLeaveRecordByDoctor(findLeaveRecordByDoctorDto));
    }
    /**
     * 管理员同意请假记录
     * @param agreeLeaveRecordDto 请假记录请求
     * @return  成功
     */
    @PostMapping("/agreeLeaveRecordByAdmin")
    public Result agreeLeaveRecord(@RequestBody AgreeLeaveRecordDto agreeLeaveRecordDto){
        return Result.success(tDoctorLeaveRecordService.agreeLeaveRecord(
                agreeLeaveRecordDto));
    }
    /**
     * 医生同意请假记录，或者拒绝
     * @param agreeLeaveRecordByDoctorDto 请假记录请求
     * @return  成功
     */
    @PostMapping("/agreeLeaveRecordByDoctor")
    public Result agreeLeaveRecordByDoctor(@RequestBody AgreeLeaveRecordByDoctorDto agreeLeaveRecordByDoctorDto){
        return Result.success(tDoctorLeaveRecordService.agreeLeaveRecordByDoctor(
                agreeLeaveRecordByDoctorDto));
    }
    /**
     * 管理员不同意请假
     * @param disagreeLeaveRecordByAdminDto 请假记录请求
     * @return  成功
     */
    @PostMapping("/disagreeLeaveRecordByAdmin")
    public Result disagreeLeaveRecordByAdmin(@RequestBody DisagreeLeaveRecordByAdminDto disagreeLeaveRecordByAdminDto){
        return Result.success(tDoctorLeaveRecordService.disagreeLeaveRecordByAdmin(
                disagreeLeaveRecordByAdminDto));
    }
}
